package com.think.archive.common;

/**
 * 常量类
 */
public class Const {
    /**
     * 返回状态
     */
    public enum ResultCode {

        SUCCESS(200, "成功"),
        VERSION(5001,"版本号不正确"),
        ERROR(5001, "失败"),
        PARAM(5003,"缺少必要的参数"),
        USER(5004,"用户不存在"),
        SIGN(5005,"sign验证不通过"),
        IP(5012,"非法ip"),
        SYSTEM_EXCEPTION(500,"系统异常"),
        ILLEGAL_TOKEN(50008,"token数据异常"),
        OTHER_CLIENTS_LOGGED_IN(50012,"token数据异常"),
        TOKEN_EXPIRED(50014,"token数据异常");

        private String value;
        private Integer code;

        ResultCode(Integer code,String value){
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public Integer getCode() {
            return code;
        }
    }

    public enum AppType {
        flow(1, "流量"),
        tel(2, "话费"),
        video(3, "视频会员"),
        audio(4, "音频"),
        virtual(5, "虚拟商品"),
        other(-1, "未知");

        private String value;
        private Integer code;

        public static AppType getAppTypeByCode(Integer code) {
            for (AppType type : AppType.values()) {
                if (type.getCode().equals(code)) {
                    return type;
                }
            }
            return other;
        }

        AppType(Integer code, String value){
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public Integer getCode() {
            return code;
        }
    }
}
